<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');
require_once ('../data_sample/mockup_data_comment.php');

class TestFunc_processMyCommentOnStatus extends UnitTestCase {
    
    function setUp(){
        global $login_button,$facebook;
        
        if(isLoggedIn()){
            try{
                $me = getOneself();
            }catch(Exception $e){
                print($login_button);
                exit();
            }
        }
    }

    //Case1: I wrote a comment on a status of one of friends (regardless of where it is)
    function test_case1(){
        global $commentCase1;
        $data = $commentCase1;
        $friends = array();
        
        processMyCommentOnStatus($friends, $data, "MY_COMMENT_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        $this->assertTrue(isset($friends['100000416787478']));
        if(isset($friends['100000416787478'])){
            $friend = $friends['100000416787478'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 1);
        }
        
    }
//    1.1: I wrote comments on statuses of one of friends (regardless of where it is)
    function test_case11(){
        global $commentCase11;
        $data = $commentCase11;
        $friends = array();
        
        processMyCommentOnStatus($friends, $data, "MY_COMMENT_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        $this->assertTrue(isset($friends['100000416787478']));
        if(isset($friends['100000416787478'])){
            $friend = $friends['100000416787478'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 2);
        }
        
    }
//    1.2: I wrote a comment on each status of two friends (regardless of where it is)
    function test_case12(){
        global $commentCase12;
        $data = $commentCase12;
        $friends = array();
        
        processMyCommentOnStatus($friends, $data, "MY_COMMENT_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 2);

        $isExistIDs =isset($friends['100000416787478']) && isset($friends['100000525262538']);
        
        $this->assertTrue($isExistIDs);
        if($isExistIDs){
            $friend = $friends['100000416787478'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 1);
            $friend = $friends['100000525262538'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 1);
        }
    }
//    1.3: I wrote comments on statuses of two friends (regardless of where it is)
    function test_case13(){
        global $commentCase13;
        $data = $commentCase13;
        $friends = array();
        
        processMyCommentOnStatus($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 2);
        
        $isExistIDs =isset($friends['100000416787478']) && isset($friends['100000525262538']);
        
        $this->assertTrue($isExistIDs);
        if($isExistIDs){
            $friend = $friends['100000416787478'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 3);
            $friend = $friends['100000525262538'];
            $this->assertEqual($friend->getNumberOfData("MY_COMMENT_ON_STATUS_FLAG"), 2);            
        }
    }
    
    function test_processMyCommentOnStatus(){ 
        $friends = array();
        $data = getMyCommentOnStatus();
        processMyCommentOnStatus($friends,$data);
        //not null
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
//        $this->assertFalse(empty($friends));
    }
}
?>
